package com.hss.rxjava.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.hss.rxjava.CheckInterface;
import com.hss.rxjava.StringUtils;


public class Address implements Parcelable ,CheckInterface {
	public String id;//在地址列表中的ID
	public String zipCode;//地址区域编码
	public String phoneNo;//配送电话
	public String consignee;//收货人姓名
	public String detailAddress;//详细地址
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getZipCode() {
		return zipCode;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	public String getPhoneNo() {
		return phoneNo;
	}
	public void setPhoneNo(String phoneNo) {
		this.phoneNo = phoneNo;
	}
	public String getConsingee() {
		return consignee;
	}
	public void setConsingee(String consingee) {
		this.consignee = consingee;
	}
	public String getDetailAddress() {
		return detailAddress;
	}
	public void setDetailAddress(String detailAddress) {
		this.detailAddress = detailAddress;
	}


	public void setValue(
			String consignee,//收货人姓名
			 String phoneNo,
			 String detailAddress,
			String zipCode){
		this.zipCode = zipCode;
		this.phoneNo = phoneNo;
		this.consignee = consignee;
		this.detailAddress = detailAddress;
	}


	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.id);
		dest.writeString(this.zipCode);
		dest.writeString(this.phoneNo);
		dest.writeString(this.consignee);
		dest.writeString(this.detailAddress);
	}

	public Address() {
	}

	protected Address(Parcel in) {
		this.id = in.readString();
		this.zipCode = in.readString();
		this.phoneNo = in.readString();
		this.consignee = in.readString();
		this.detailAddress = in.readString();
	}

	public static final Creator<Address> CREATOR = new Creator<Address>() {
		@Override
		public Address createFromParcel(Parcel source) {
			return new Address(source);
		}

		@Override
		public Address[] newArray(int size) {
			return new Address[size];
		}
	};

	@Override
	public boolean check(int index) {
		if(!StringUtils.isNotNull(zipCode,phoneNo,consignee,detailAddress))return false;
		if(!StringUtils.isValidate(id))return false;
		return true;
	}

	@Override
	public void fix(int index) {
		zipCode = StringUtils.makeStringNotNull(zipCode);
		phoneNo = StringUtils.makeStringNotNull(phoneNo);
		consignee = StringUtils.makeStringNotNull(consignee);
		detailAddress = StringUtils.makeStringNotNull(detailAddress);
	}
}
